/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2024-04-26 13:43:26
 * @LastEditors: icymoon911 icymoon911@163.com
 * @LastEditTime: 2024-07-31 14:16:05
 * @FilePath: \ken147258.topayClient\src\api\auth\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { CaptchaResult, LoginData, LoginResult } from "./types";

const URL = {
  loginByOther: '/auth/login',
  loginByPayer: '/payerApi/login',
  loginByPayee: '/skfApi/login',
  logoutByOther: '/auth/logout',
  logoutByPayer: '/payerApi/login/out',
  logoutByPayee: '/skfApi/login/out',

  loginForTwiceByOther: '/platformApi/twice/login',
  loginForTwiceByPayer: '/xxxxxx',
  loginForTwiceByPayee: '/skfApiApi/twice/login',

  login: '/auth/login',
  logout: '/auth/logout',
  getCaptchaApi: '/auth/getCaptcha',
};

/**
 * 登录API
 *
 * @param data {LoginData}
 * @returns
 */
export function login(data: LoginData): AxiosPromise<any> {
  return request({
    url: URL.login,
    method: "post",
    data: data,
  });
}
export function loginByOther(data: LoginData): AxiosPromise<any> {
  return request({
    url: URL.loginByOther,
    method: "post",
    data: data,
  });
}
export function loginByPayer(data: LoginData): AxiosPromise<any> {
  return request({
    url: URL.loginByPayer,
    method: "post",
    data: data,
  });
}
export function loginByPayee(data: LoginData): AxiosPromise<any> {
  return request({
    url: URL.loginByPayee,
    method: "post",
    data: data,
  });
}

export function loginForTwiceByOther(data: Object): AxiosPromise<any> {
  return request({
    url: URL.loginForTwiceByOther,
    method: "post",
    data: data,
  });
}
export function loginForTwiceByPayer(data: Object): AxiosPromise<any> {
  return request({
    url: URL.loginForTwiceByPayer,
    method: "post",
    data: data,
  });
}
export function loginForTwiceByPayee(data: Object): AxiosPromise<any> {
  return request({
    url: URL.loginForTwiceByPayee,
    method: "post",
    data: data,
  });
}

/**
 * 注销API
 */
export function logoutApiByOther() {
  return request({
    url: URL.logoutByOther,
    method: "get",
  });
}
export function logoutApiByPayer() {
  return request({
    url: URL.logoutByPayer,
    method: "get",
  });
}
export function logoutApiByPayee() {
  return request({
    url: URL.logoutByPayee,
    method: "get",
  });
}
export function logout() {
  return request({
    url: URL.logout,
    method: "get",
  });
}

/**
 * 获取验证码
 */
export function getCaptchaApi(): AxiosPromise<CaptchaResult> {
  return request({
    url: URL.getCaptchaApi,
    method: "get",
  });
}
